const bodyParser=require("body-parser");
const Mock=require("mockjs");
const data=Mock.mock({
    "list|11-50":[{
        img: '@image(50x50,@color)',
        title: '@ctitle(2,4)',
        id: '@id'
    }]
})

module.exports = {
    devServer:{
        before(app)
        {
            app.use(bodyParser.json())
            app.post("/toLogin",(req,res)=>
            {
                console.log("----",req.body);
                if(req.body.username=="lmh" && req.body.password=="123")
                {
                    res.send({
                        code:200,
                        msg:"登录成功",
                    })
                }
                else
                {
                    res.send({
                        code:400,
                        msg:"登录失败"
                    })
                }
            })
            app.get("/list",(req,res)=>
            {
                res.send(data.list);
            })
        }
    }
}